package com.study.domain;

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Objects;

/**
 * Created by think on 2016/7/28.
 */
public class Role implements RowMapper<Role>{
    public int id;
    public String text;
    public String urlName;
    public String iconCls;
    public String state;  //节点状态，'open' 或 'closed'，默认：'open'。如果为'closed'的时候，将不自动展开该节点。
    public boolean checked;  //表示该节点是否被选中。
    public int parentId;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getUrlName() {
        return urlName;
    }

    public void setUrlName(String urlName) {
        this.urlName = urlName;
    }

    public String getIconCls() {
        return iconCls;
    }

    public void setIconCls(String iconCls) {
        this.iconCls = iconCls;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }


    @Override
    public Role mapRow(ResultSet rs, int index) throws SQLException {
        Role role = new Role();
        role.setId(rs.getInt("id"));
        role.setText(rs.getString("text"));
        role.setUrlName(rs.getString("url_name"));
        role.setIconCls(rs.getString("iconCls"));
        role.setState(rs.getString("state"));
        role.setChecked(rs.getInt("checked") == 1 ? true : false);
        role.setParentId(rs.getInt("parent_id"));
        return role;
    }
}
